package com.zxing.practice.config.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class AjaxResult {

    private Integer code;
    private String msg;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object data;

    public static AjaxResult success() {
        return new AjaxResult().setCode(200).setMsg("操作成功");
    }

    public static AjaxResult success(String msg) {
        return new AjaxResult().setCode(200).setMsg(msg);
    }

    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult().setCode(200).setMsg(msg).setData(data);
    }

    public static AjaxResult error(Integer code, String msg) {
        return new AjaxResult().setCode(code).setMsg(msg);
    }
}
